﻿using System;
using System.Web.UI;
using System.Web.Caching;
using System.Diagnostics;
using log4net;

namespace SpeakOut.Lib.Web
{
    public class CachedUserControl : BaseUserControl
    {
        private static readonly ILog _log = LogManager.GetLogger(typeof(CachedUserControl));

        protected virtual void Page_Load(object sender, EventArgs e)
        {
            _log.DebugFormat("Control not cached at: {0}", DateTime.Now);

            BasePartialCachingControl basePartialCachingControl = Parent as BasePartialCachingControl;

            if (basePartialCachingControl != null)
            {
                basePartialCachingControl.Dependency = new CacheDependency(null, new[] {BlogConfig.CacheDependecyKey});
            }
        }
    }
}
